package com.uatair.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.uatair.common.annotation.Log;
import com.uatair.common.core.controller.BaseController;
import com.uatair.common.core.domain.AjaxResult;
import com.uatair.common.enums.BusinessType;
import com.uatair.system.domain.TpRecode;
import com.uatair.system.service.ITpRecodeService;
import com.uatair.common.utils.poi.ExcelUtil;
import com.uatair.common.core.page.TableDataInfo;

/**
 * 请求历史记录Controller
 * 
 * @author uatair
 * @date 2025-06-20
 */
@RestController
@RequestMapping("/system/recode")
public class TpRecodeController extends BaseController
{
    @Autowired
    private ITpRecodeService tpRecodeService;

    /**
     * 查询请求历史记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:recode:list')")
    @GetMapping("/list")
    public TableDataInfo list(TpRecode tpRecode)
    {
        startPage();
        List<TpRecode> list = tpRecodeService.selectTpRecodeList(tpRecode);
        return getDataTable(list);
    }

    /**
     * 导出请求历史记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:recode:export')")
    @Log(title = "请求历史记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TpRecode tpRecode)
    {
        List<TpRecode> list = tpRecodeService.selectTpRecodeList(tpRecode);
        ExcelUtil<TpRecode> util = new ExcelUtil<TpRecode>(TpRecode.class);
        util.exportExcel(response, list, "请求历史记录数据");
    }

    /**
     * 获取请求历史记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:recode:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tpRecodeService.selectTpRecodeById(id));
    }

    /**
     * 新增请求历史记录
     */
    @PreAuthorize("@ss.hasPermi('system:recode:add')")
    @Log(title = "请求历史记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TpRecode tpRecode)
    {
        return toAjax(tpRecodeService.insertTpRecode(tpRecode));
    }

    /**
     * 修改请求历史记录
     */
    @PreAuthorize("@ss.hasPermi('system:recode:edit')")
    @Log(title = "请求历史记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TpRecode tpRecode)
    {
        return toAjax(tpRecodeService.updateTpRecode(tpRecode));
    }

    /**
     * 删除请求历史记录
     */
    @PreAuthorize("@ss.hasPermi('system:recode:remove')")
    @Log(title = "请求历史记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tpRecodeService.deleteTpRecodeByIds(ids));
    }
}
